package com.yqy.spring.service;

/**
 * 静态代理模式
 * 采用的是关联关系，所以程序的耦合度较低
 * 但是还有2个缺点
 * ①类爆炸问题
 * ②代码复用问题
 */
public class OrderServiceStaticProxy implements  OrderService{
    private OrderService orderService;
    public OrderServiceStaticProxy(OrderService orderService) {
        this.orderService = orderService;
    }
    @Override
    public void generate() {
        long begin=System.currentTimeMillis();
        orderService.generate();
        long end=System.currentTimeMillis();
        System.out.println("耗时"+(end-begin)+"毫秒");
    }



    @Override
    public void detail() {
        long begin=System.currentTimeMillis();
        orderService.detail();
        long end=System.currentTimeMillis();
        System.out.println("耗时"+(end-begin)+"毫秒");
    }

    @Override
    public void modify() {
        long begin=System.currentTimeMillis();
        orderService.modify();
        long end=System.currentTimeMillis();
        System.out.println("耗时"+(end-begin)+"毫秒");
    }
}
